import pandas as pd


def signal(df: pd.DataFrame, *args, **kwargs) -> pd.DataFrame:
    n: int = args[0]
    factor_name = kwargs.get('column', __name__)
    df.sort_values(by='open_time', ascending=True, inplace=True)
    df[factor_name] = df.groupby(['symbol', 'trade_type'])['close'].pct_change(n)
    return df
